﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AggregateRoot.Console
{
    public class SupplierRepository
    {
        DataContext _db;

        public SupplierRepository()
        {
            _db = new DataContext();
        }

        public SupplierRepository(DataContext db)
        {
            _db = db;
        }

        public Supplier GetBySupplierId(int SupplierId)
        {
            return _db.Suppliers.SingleOrDefault(o => o.SupplierID == SupplierId);
        }

        public void Add(Supplier Supplier)
        {
            _db.Suppliers.AddObject(Supplier);
        }

        public void Delete(Supplier Supplier)
        {
            _db.Suppliers.DeleteObject(Supplier);
        }

        public void Save()
        {
            _db.SaveChanges();
        }
    }
}
